package biz.obake.team.touchprotector.ui;

import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import biz.obake.team.touchprotector.R;
import biz.obake.team.touchprotector.features.proximity.b;
import biz.obake.team.touchprotector.features.proximity.c;
import biz.obake.team.touchprotector.g.a;

public class Tab_Proximity extends a {
    public void onCreatePreferences(Bundle bundle, String str) {
        setPreferencesFromResource(R.xml.ui_tab_proximity, str);
        if (b.e()) {
            prefRemove("sensor_unavailable");
        } else {
            PreferenceScreen preferenceScreen = getPreferenceScreen();
            for (int L0 = preferenceScreen.L0() - 1; L0 >= 0; L0--) {
                Preference K0 = preferenceScreen.K0(L0);
                if (!"sensor_unavailable".equals(K0.o())) {
                    preferenceScreen.O0(K0);
                }
            }
        }
        if (!c.e()) {
            prefRemove("proximity_lock_if_dark");
        }
    }

    /* access modifiers changed from: protected */
    public void onPrefChanged(SharedPreferences sharedPreferences, String str) {
        if (str.equals("unlock_proximity") && a.g("unlock_proximity")) {
            prefSwitch("unlock_proximity_uncovered", false);
            prefSwitch("unlock_proximity_uncovered_force", false);
        }
        if (str.equals("unlock_proximity_uncovered") && a.g("unlock_proximity_uncovered")) {
            prefSwitch("unlock_proximity", false);
            prefSwitch("unlock_proximity_uncovered_force", false);
        }
        if (str.equals("unlock_proximity_uncovered_force") && a.g("unlock_proximity_uncovered_force")) {
            prefSwitch("unlock_proximity", false);
            prefSwitch("unlock_proximity_uncovered", false);
        }
        if (str.equals("lock_proximity") && !a.g("lock_proximity")) {
            prefSwitch("unlock_proximity_uncovered", false);
        }
        if (str.equals("unlock_proximity_uncovered") && a.g("unlock_proximity_uncovered")) {
            prefSwitch("lock_proximity", true);
        }
    }

    /* access modifiers changed from: protected */
    public void onUpdateDisplay() {
        Preference H0 = getPreferenceScreen().H0("proximity_sensitivity");
        if (H0 != null) {
            String w = biz.obake.team.touchprotector.c.w(R.string.ui_tab_proximity_sensitivity_summary_cm);
            String w2 = biz.obake.team.touchprotector.c.w(R.string.ui_tab_proximity_sensitivity_summary_sec);
            String w3 = biz.obake.team.touchprotector.c.w(R.string.ui_tab_proximity_sensitivity_summary_auto);
            String w4 = biz.obake.team.touchprotector.c.w(R.string.ui_tab_proximity_sensitivity_summary_disabled);
            String l = a.l("proximity_distance");
            if (!"auto".equals(l)) {
                w3 = w.replace("{0}", l);
            }
            String replace = w2.replace("{0}", Float.toString(Float.parseFloat(a.l("proximity_sensitivity")) / 1000.0f));
            String replace2 = w2.replace("{0}", Float.toString(Float.parseFloat(a.l("proximity_sensitivity_uncovered")) / 1000.0f));
            String l2 = a.l("proximity_false_testing");
            if (!"disabled".equals(l2)) {
                w4 = w2.replace("{0}", Float.toString(Float.parseFloat(l2) / 1000.0f));
            }
            H0.v0(biz.obake.team.touchprotector.c.w(R.string.ui_tab_proximity_sensitivity_summary).replace("{0}", w3).replace("{1}", replace).replace("{2}", replace2).replace("{3}", w4));
        }
    }
}
